﻿using System;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.Networking;

[RequireComponent(typeof(AI))]
public abstract class AIBehaviour : NetworkBehaviour
{
    protected AIBehaviour()
    {
    }

    protected virtual void Awake()
    {
        this.aiBase = base.GetComponent<AI>();
    }

    public override void OnDeserialize(NetworkReader reader, bool initialState)
    {
    }

    public override bool OnSerialize(NetworkWriter writer, bool forceAll)
    {
        bool flag;
        return flag;
    }

    public override void OnStartClient()
    {
        base.OnStartClient();
        if (!base.hasAuthority)
        {
            if ((this is AILook) || (this is AITargetDetector))
            {
                if (this.look != null)
                {
                    this.look.disableNetwork = true;
                }
            }
            else
            {
                UnityEngine.Object.Destroy(this);
            }
        }
    }

    protected virtual void Start()
    {
    }

    private void UNetVersion()
    {
    }

    public AI aiBase { get; private set; }

    public Attack attack
    {
        get
        {
            return this.aiBase.attack;
        }
    }

    public float attackRange
    {
        get
        {
            return ((this.weapon == null) ? 0f : this.weapon.attackRange);
        }
    }

    public Character character
    {
        get
        {
            return this.aiBase.character;
        }
    }

    public GameObject detectedTarget
    {
        get
        {
            return ((this.targetDetector == null) ? null : this.targetDetector.target);
        }
    }

    public Inventory inventory
    {
        get
        {
            return this.aiBase.inventory;
        }
    }

    public bool isMonster
    {
        get
        {
            return (base.tag == GameTags.Monster);
        }
    }

    public bool isWeaponCoolingDown
    {
        get
        {
            return ((this.weapon != null) && this.weapon.isCoolingdown);
        }
    }

    public Life life
    {
        get
        {
            return this.aiBase.life;
        }
    }

    public Look look
    {
        get
        {
            return this.aiBase.look;
        }
    }

    public Move move
    {
        get
        {
            return this.aiBase.move;
        }
    }

    public Vector3 position
    {
        get
        {
            return this.aiBase.position;
        }
        set
        {
            this.aiBase.position = value;
        }
    }

    public GameObject self
    {
        get
        {
            return this.aiBase.self;
        }
    }

    public AITargetDetector targetDetector
    {
        get
        {
            return this.aiBase.targetDetector;
        }
    }

    public Weapon weapon
    {
        get
        {
            return ((this.attack == null) ? null : this.attack.weapon);
        }
        set
        {
            if (this.attack != null)
            {
                this.attack.weapon = value;
            }
        }
    }
}

